<?php
/* @var $this SlidehomeController */
/* @var $model Slidehome */
/* @var $form CActiveForm */
$request = Yii::app()->request;
if ($request->enableCsrfValidation) {
    echo CHtml::metaTag($request->getCsrfToken(), 'csrf-token');
    echo CHtml::metaTag($request->csrfTokenName, 'csrf-param');
}
?>

<div class="form">
    <?php $form = $this->beginWidget('CActiveForm', array(
    'id' => 'slidehome-form',
    'enableAjaxValidation' => false,)); ?>
    <?php $idImage = sha1(uniqid() . Now('yyyyMMddhhmmss'));
    echo CHtml::hiddenField('image_name_tmp', $idImage);?>

    <?php echo $form->errorSummary($model); ?>
    <table border="0" cellpadding="0" cellspacing="0" id="id-form">
        <tr>
            <th valign="top">File Gambar</th>
            <td class="idform">
                <div id="cropImg"><?php echo $model->isNewRecord ? "" :
                    "<img id='image' src='" . bu() . '/img/slidehome/' . $model->id . '.jpg' .
                        "' style=\"width: 100px; height: 100px; margin-left: 0px; margin-bottom: 10px;\">"; ?></div>
                <?php
                $this->widget('ext.EAjaxUpload.EAjaxUpload', array(
                        'id' => 'uploadFile',
                        'postParams' => array('tmp' => $idImage),
                        'config' => array(
                            'action' => $this->createUrl('/backend/slidehome/upload'),
                            'allowedExtensions' => array("jpg", "jpeg", "gif", "png"),
                            //array("jpg","jpeg","gif","exe","mov" and etc...
                            'sizeLimit' => 500 * 1024,
                            // maximum file size in bytes       //$('#cropDialog').dialog('open');
                            'minSizeLimit' => 10,
                            //*1024*1024,// minimum file size in bytes $('.qq-upload-button').css('display', 'none');
                            'onComplete' => "js:function(id, fileName, responseJSON){
                                        $('#uploadFile').hide();
                                        if (responseJSON.success) {
                                                $('#cropImg').load('" . $this->createUrl('/backend/slidehome/cropImg') . "/'+responseJSON.filename);
                                                $('#Users_image').val(responseJSON.filename);
                                                $('#Users_imageExt').val((responseJSON.filename.substring(responseJSON.filename.lastIndexOf('.'))).toLowerCase());
                                                $('#uploadFile').show();
                                        } else {
                                                $('#uploadFile').html('<p  width=\"160\">' + responseJSON.error +'</p>');
                                        }
                                }",
                            'messages' => array(
                                'typeError' => "{file} has invalid extension. Only {extensions} are allowed.",
                                'sizeError' => "{file} is too large, maximum file size is {sizeLimit}.",
                                'minSizeError' => "{file} is too small, minimum file size is {minSizeLimit}.",
                                'emptyError' => "{file} is empty, please select files again without it.",
                                'onLeave' => "The files are being uploaded, if you leave now the upload will be cancelled."),
                            'showMessage' => "js:function(message){ alert(message); }")));
                ?>
            </td>
            <td class="idform">
            </td>
        </tr>
        <tr>
            <th valign="top"><?php echo $model->getAttributeLabel('ket'); ?></th>
            <td class="idform">
                <?php $this->widget('ext.tinymce.TinyMce', array(
                    'model' => $model,
                    'attribute' => 'ket',
                    'fileManager' => array(
                        'class' => 'ext.elFinder.TinyMceElFinder',
                        'connectorRoute' => 'elfinder/connector',),
                    'htmlOptions' => array('rows' => 6, 'cols' => 60,),)); ?>
            </td>
            <td class="idform">
                <?php if ($model->hasErrors('ket')) echo "<div class='error-left'></div>"; ?>
                <?php echo $form->error($model, 'ket', array('class' => 'error-inner')); ?>
            </td>
        </tr>
       <!-- <tr>
            <th valign="top"><?//php echo $model->getAttributeLabel('notes'); ?></th>
            <td class="idform">
                <?//php $this->widget('ext.tinymce.TinyMce', array(
                   // 'model' => $model,
                  //  'attribute' => 'notes',
//                    'fileManager' => array(
//                        'class' => 'ext.elFinder.TinyMceElFinder',
//                        'connectorRoute' => 'elfinder/connector',),
//                    'htmlOptions' => array('rows' => 6, 'cols' => 60,),)); ?>
            </td>
            <td class="idform">
                <?//php if ($model->hasErrors('notes')) echo "<div class='error-left'></div>"; ?>
                <?//php echo $form->error($model, 'notes', array('class' => 'error-inner')); ?>
            </td>
        </tr>-->
        <tr>
            <th valign="top"><?php echo $model->getAttributeLabel('url'); ?></th>
            <td class="idform">
                <?php echo $form->textField($model, 'url',
                array('size' => 60, 'maxlength' => 250, 'class' => 'inp-form')); ?>
            </td>
            <td class="idform">
                <?php if ($model->hasErrors('url')) echo "<div class='error-left'></div>"; ?>
                <?php echo $form->error($model, 'url', array('class' => 'error-inner')); ?>
            </td>
        </tr>
        <tr>
            <th>&nbsp;</th>
            <td valign="top">
                <?php echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save',
                array('class' => 'form-submit')); ?>
            </td>
            <td class="idform"></td>
        </tr>
    </table>
    <?php $this->endWidget(); ?>
</div><!-- form -->